local class = require('lib/middleclass')
local ai = class('AIType1') --

ai.BT = nil 

--框架方法
function ai:initialize(param1, param2)
  print('ai initialized')
  self.param1 = param1
  self.param2 = param2
  self.BT = BT:new({
  object = {name = param1},
  tree = BT.Sequence:new({
    nodes = {
      BT.Task:new({
        run = function(task, object)
          print(object.name .. " looking" .. self.param1)
          task:success()
        end
      }),
      BT.Random:new({
        nodes = {
          BT.Task:new({
            run = function(task, object)
              print(object.name .. " walk left")
              task:success()
            end
          }),
          BT.Task:new({
            run = function(task, object)
              print(object.name .. " walk up")
              task:success()
            end
          }),
          BT.Task:new({
            run = function(task, object)
              print(object.name .. " walk right")
              task:success()
            end
          }),
          BT.Task:new({
            run = function(task, object)
              print(object.name .. " walk down")
              task:success()
            end
          }),
        }
      }),
    }
  })
})
end

function ai:update()
--  print('ai test' .. self.param1)
  self.BT:run()
end

return ai
